package letsjava.pattern.composite;

public class Cabinet extends CompositeEquipment {
	public static void main(String[] args){
		
		Cabinet cabinet=new Cabinet("Tower"); 
		Chassis chassis=new Chassis("PC Chassis"); 
		//将PC Chassis装到Tower中 (将盘盒装到箱子里) 
		cabinet.add(chassis);
		
		chassis.add(new Disk("10 GB")); 
		chassis.add(new Disk("20 GB")); 
		//调用 netPrice()方法; 
		System.out.println("netPrice="+cabinet.netPrice()); 
		System.out.println("discountPrice="+cabinet.discountPrice());
		
	}
	
	
	public Cabinet(String name) {
		super(name);
	}

	public double netPrice() {
		return 1. + super.netPrice();
	}

	public double discountPrice() {
		return .5 + super.discountPrice();
	}
}